<?php

namespace App\Http\Controllers;

use App\Facades\Tx;
use App\Models\Complain;
use Illuminate\Http\Request;

class ComplainController extends Controller
{
    public function index()
    {
        $list = Complain::where('uid',\Auth::id())->paginate();
        return Tx::success($list);
    }

    public function show(Request $request,Complain $complain)
    {
        return Tx::success($complain);
    }

    public function store(Request $request)
    {
        $this->validate($request,
        [
           'order_id' => 'required',
           'description' => 'required',
        ]);

        Complain::create(['order_id'=>$request->get('order_id'), 'description'=>$request->get('description')]);
        return Tx::success("","提交成功");
    }
}
